﻿


using System;
using AutoMapper;
using Demo.Domain;
using Demo.DataObjects;

namespace Demo.Application
{
    public class ApplicationService
    {
        public static void Initialize()
        {
            //Mapper.CreateMap<UserDTO, User>()
            //    .ForMember(dto => dto.Name, us => us.ResolveUsing(u => u.Name))
            //    .ForMember(dto => dto.Password, us => us.ResolveUsing(u => u.Password))
            //    .ForMember(dto => dto.RoleID, us => us.ResolveUsing(u => u.RoleID))
            //    .ForMember(dto => dto.UserID, us => us.ResolveUsing(u => u.UserID));

            Mapper.CreateMap<User, UserDTO>()
                .ForMember(dto => dto.Name, us => us.ResolveUsing(u => u.Name))
                .ForMember(dto => dto.Password, us => us.ResolveUsing(u => u.Password))
                .ForMember(dto => dto.RoleID, us => us.ResolveUsing(u => u.RoleID))
                .ForMember(dto => dto.UserID, us => us.ResolveUsing(u => u.UserID));
            Mapper.CreateMap<Demo.Domain.Action, ActionDTO>()
                .ForMember(dto => dto.ActionID, ad => ad.ResolveUsing(a => a.ActionID))
                .ForMember(dto => dto.ModuleID, ad => ad.ResolveUsing(a => a.ModuleID))
                .ForMember(dto => dto.Name, ad => ad.ResolveUsing(a => a.Name))
                .ForMember(dto => dto.Sort, ad => ad.ResolveUsing(a => a.Sort));
            Mapper.CreateMap<Module, ModuleDTO>()
                .ForMember(dto => dto.ModuleID, mo => mo.ResolveUsing(m => m.ModuleID))
                .ForMember(dto => dto.Name, mo => mo.ResolveUsing(m => m.Name))
                .ForMember(dto => dto.Sort, mo => mo.ResolveUsing(m => m.Sort));
        }
    }
}
